//
//  main.swift
//  TestSwift
//
//  Created by liuxin on 2020/1/14.
//  Copyright © 2020 liuxin. All rights reserved.
//

import Foundation
//sdfdsfdssdfsdf
//fdsdsffsdfsdfdf
//sdfdsfdssdfsdfdfs
//sdfdsfdssdfsdf

enum TestEnum {
    case test0 (String,String)
    case test1 (Int, Int, Int)
    case test2 (Int, Int)
    case test3 (Int)
    case test4 (Bool)
    case test5
}

//var t = TestEnum.test1(5, 6, 7)
//print(Mems.ptr(ofVal: &t))
//t = TestEnum.test2(8, 9)
//t = TestEnum.test3(10)
//t = TestEnum.test4(true)
//t = TestEnum.test5

//t = TestEnum.test2
//t = TestEnum.test3

func testStruct() {
    struct Point {
        var x : Int
        var y : Int
    }
    
    var p = Point(x: 10, y: 20)
    print("Mems.ptr(ofVal: &point)",Mems.ptr(ofVal: &p))
    print("Mems.memStr(ofVal: &point)",Mems.memStr(ofVal: &p))
    
    var p1 = Point(x: 11, y: 22)
    print("Mems.ptr(ofVal: &point)",Mems.ptr(ofVal: &p1))
    print("Mems.memStr(ofVal: &point)",Mems.memStr(ofVal: &p1))
    p = p1
    print("Mems.ptr(ofVal: &point)",Mems.ptr(ofVal: &p))
    print("Mems.memStr(ofVal: &point)",Mems.memStr(ofVal: &p))
    p1.x = 33
    print("sss点点滴滴ß")
    print("Mems.memStr(ofVal: &point)",Mems.memStr(ofVal: &p))
    print("Mems.memStr(ofVal: &point)",Mems.memStr(ofVal: &p1))
    print("sssss")
}

testStruct()

func textClassAndStruct() {
    class Size {
        var width = 1
        var height = 2
    }
    
    struct Point {
        var x = 3
        var y = 4
    }
    
    print("MemoryLayout<Size>.stride",MemoryLayout<Size>.stride)
    print("MemoryLayout<Point>.stride",MemoryLayout<Point>.stride)
    
    var size = Size()
    print("Mems.ptr(ofVal: &size)",Mems.ptr(ofVal: &size))
    print("Mems.memStr(ofVal: &size)",Mems.memStr(ofVal: &size))
    
    print("Mems.ptr(ofRef: &size)",Mems.ptr(ofRef: size))
    print("Mems.memStr(ofRef: &size)",Mems.memStr(ofRef: size))
    
    var point = Point()
    print("Mems.ptr(ofVal: &point)",Mems.ptr(ofVal: &point))
    print("Mems.memStr(ofVal: &point)",Mems.memStr(ofVal: &point))
}

//textClassAndStruct()


